<?php

namespace SinoPHP\BbdBoss\Model;

use Upfor\UpforPHP\Model;

class InnerDomain extends Model {
    
    /**
     * 获取内部域名列表
     *
     * 支持分页
     * 
     * @param  array   $where
     * @param  integer $pageNumber
     * @param  integer $pageSize
     * @param  arary   $orderBy
     * @return array
     */
    public function getDomainList($where = null, $pageNumber = 1, $pageSize = 20, $orderBy = null) {
        $this->db->table($this->getTableName())->field([
            'inner_domain_id',
            'domain_name',
            'domain_suffix',
            'admin_real_name',
            'create_time',
            'update_time'
        ]);

        $this->db->where($where);

        $this->db->page($pageNumber, $pageSize);

        if ($orderBy) {
            $this->db->order($orderBy);
        }

        return $this->db->getList();
    }

    /**
     *功能介绍:查看当前域名是否存在
     */

    public function configDomainFind($id){
          $map['inner_domain_id']=intval($id);
          $field='*';
          $domainArray = $this->getRow($field,$map);
          return $domainArray;
    }

    /**
     *功能介绍：获取内部域名列表信息
     */
    public function getInnerDomain(){
        $field='inner_domain_id,domain_name,domain_suffix';
        $domainArrayAll =  $this->getList($field);
        if(!empty($domainArrayAll) && is_array($domainArrayAll)){
            foreach ($domainArrayAll as $key=>$val){
                $domainArrayAll[$key]['domain_suffix_name'] = $val['domain_name'].$val['domain_suffix'];
            }
        }
        return $domainArrayAll;
    }

}
